package com.jbit.service.impl;

import com.jbit.dto.DmUser;
import com.jbit.mapper.DmUserMapper;
import com.jbit.service.DmUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 用户表(DmUser)表服务实现类
 *
 * @author makejava
 * @since 2023-07-22 09:12:31
 */
@Service("dmUserService")
public class DmUserServiceImpl implements DmUserService {
    @Resource
    private DmUserMapper dmUserMapper;

    @Override
    public DmUser queryUserByPhone(String phone) {
        return dmUserMapper.queryUserByPhone(phone);
    }

    @Override
    public Integer addUser(DmUser dmUser) {
        return dmUserMapper.addUser(dmUser);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public DmUser queryById(Long id) {
        return this.dmUserMapper.queryById(id);
    }


    /**
     * 新增数据
     *
     * @param dmUser 实例对象
     * @return 实例对象
     */
    @Override
    public DmUser insert(DmUser dmUser) {
        this.dmUserMapper.insert(dmUser);
        return dmUser;
    }

    /**
     * 修改数据
     *
     * @param dmUser 实例对象
     * @return 实例对象
     */
    @Override
    public DmUser update(DmUser dmUser) {
        this.dmUserMapper.update(dmUser);
        return this.queryById(dmUser.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.dmUserMapper.deleteById(id) > 0;
    }
}
